package com.example.mhandler;

import android.util.Log;
import android.widget.TextView;

import com.example.mhandler.MyHandler;
import com.example.mhandler.MyMessage;
import com.example.mhandler.MyTextView;


public class MyActivity {
    private static final String TAG = "MyActivity";

    private MyTextView mytextview=new MyTextView();
    private H mH=new H();

    public void onCreat(){
        //主线程更新UI
        System.out.println("执行onCreat");
        mytextview.setText();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(5000);
                    //子线程更新UI
                   // mytextview.setText();
                    MyMessage message=new MyMessage();
                    message.obj="消息";
                    mH.sendMessage(message);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }

    public void onResume(){
        System.out.println("onResume");
    }

    private class  H extends MyHandler {

        public  void     handlerMessage(MyMessage message){
            String data= (String) message.obj;
            System.out.println("handler中更新了"+data);
            mytextview.setText();
        }
    }
}